var app = getApp(), util = require("../../../resource/js/util.js"), $ = require("../../../resource/utils/underscore"), WxParse = require("../../../resource/wxParse/wxParse.js"), _function = require("../../../resource/function/function.js");

Page({
    data: {
        datum: [],
        uid: 0,
        tk: !1,
        title: "",
        is_pay: !1,
        nav: [],
        music: 0,
        wxapp_article_newtitle: "",
        wxapp_article_hottitle: "",
        wxapp_serialize_newtitle: ""
    },
    onLoad: function(t) {
        _function.system(this, 1);
        var e = decodeURIComponent(t.scene);
        "undefined" != e ? (wx.setStorageSync("fxid", e), wx.setStorageSync("fx_pay_type", "scene")) : t.fxid && t.fxtype && (wx.setStorageSync("fxid", t.fxid), 
        wx.setStorageSync("fx_pay_type", "share")), this.getDatum();
        var a = wx.getStorageSync("music");
        this.setData({
            music: a
        });
    },
    onPullDownRefresh: function() {
        this.getDatum(), wx.stopPullDownRefresh();
    },
    getDatum: function() {
        var a = this;
        _function.request("entry/wxapp/Index", {}, "", function(t) {
            if (a.setData({
                datum: t
            }), t.modules) {
                wx.setStorageSync("is_pay", t.modules.is_pay);
                var e = wx.getStorageSync("is_pay");
                a.setData({
                    is_pay: 1 == e
                }), a.setData({
                    wxapp_article_newtitle: t.modules.wxapp_article_newtitle
                }), a.setData({
                    wxapp_article_hottitle: t.modules.wxapp_article_hottitle
                }), a.setData({
                    wxapp_serialize_newtitle: t.modules.wxapp_serialize_newtitle
                });
            }
        }, this, "POST");
    },
    swiper: function(t) {
        var e = t.currentTarget.dataset.appid, a = t.currentTarget.dataset.urlone.indexOf("http");
        if (e) return wx.navigateToMiniProgram({
            appId: e,
            path: t.currentTarget.dataset.url
        }), !1;
        wx.getStorageSync("userInfo") || _function.getUserinfo(this), -1 == a ? wx.navigateTo({
            url: t.currentTarget.dataset.urlone
        }) : wx.navigateTo({
            url: "../outside/index?url=" + t.currentTarget.dataset.url
        });
    },
    detail: function(t) {
        var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.authorid, r = t.currentTarget.dataset.url, i = t.currentTarget.dataset.type;
        "music" == i && (e = wx.getStorageSync("music"));
        var n = wx.getStorageSync("userInfo");
        n ? (this.setData({
            uid: n.id
        }), this.detailTwo(e, r, i, n.id, a)) : _function.getUserinfo(this);
    },
    detailTwo: function(e, a, t, r, i) {
        if (2 == t) wx.navigateTo({
            url: a + "?id=" + e
        }); else {
            var n = wx.getStorageSync("userInfo");
            _function.request("entry/wxapp/Judge", {
                uid: r,
                id: e
            }, "", function(t) {
                0 == t && n.author != i ? _function.hint(3, "抱歉,该课程仅限指定分组用户阅览^_^!", "温馨提示", function(t) {}) : wx.navigateTo({
                    url: a + "?id=" + e
                });
            }, this);
        }
    },
    more: function(t) {
        var e = t.currentTarget.dataset.types, a = t.currentTarget.dataset.url, r = t.currentTarget.dataset.appid, i = t.currentTarget.dataset.path, n = wx.getStorageSync("userInfo");
        if (r) return wx.navigateToMiniProgram({
            appId: r,
            path: i,
            success: function(t) {
                console.log("打开成功");
            }
        }), !1;
        n ? a || r ? wx.navigateTo({
            url: a
        }) : wx.navigateTo({
            url: "../art_list/index?types=" + e
        }) : _function.getUserinfo(this);
    },
    formSubmit: function(t) {
        var e = t.detail.value.title;
        if ("" == e) return _function.hint(3, "请输入关键词^_^!", "温馨提示", function(t) {}), !1;
        wx.navigateTo({
            url: "../search/index?title=" + e + "&type=1"
        }), this.setData({
            title: ""
        });
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("share_title");
        return 0 != this.data.uid ? {
            title: t,
            path: "dg_costread/pages/newcms/index/index?fxid=" + this.data.uid + "&fxtype=fx"
        } : {
            title: t,
            path: "dg_costread/pages/newcms/index/index"
        };
    }
});